@extends('admin/layout/master')
@section('title', '评论列表')
@section('title2', '评论列表')

@section('static')
    <script src="/plus/My97DatePicker/WdatePicker.js"></script>
@endsection

@section('action')
    <a class="layui-btn layui-btn-small layui-btn-normal usersAdd_btn" href="{{ url('/admin/article/index') }}"><i class="layui-icon"></i>文章管理</a>
@endsection

@section('content')
    <form class="layui-field-box layui-form" action="{{ url('/admin/comment/index') }}" method="get">
        <div class="layui-form-item">
            <label class="layui-form-label">搜索：</label>
            <div class="layui-inline">
                <input type="text" name="article_id" placeholder="文章ID" value="{{ $request->input('article_id') }}" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline">
                <input type="text" name="nickname" placeholder="昵称" value="{{ $request->input('nickname') }}" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline">
                <input type="text" name="email" placeholder="邮箱" value="{{ $request->input('email') }}" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-inline">
                <select name="is_show" lay-verify="">
                    <option value="">审核类型</option>
                    <option value="1" {{ $request->input('is_show') == 1 ? "selected" : "" }}>审核通过</option>
                    <option value="2" {{ $request->input('is_show') == 2 ? "selected" : "" }}>未审核</option>
                </select>
            </div>
            <button class="layui-btn"><i class="layui-icon"></i> </button>
            <a href="{{ url('/admin/comment/index') }}" class="layui-btn layui-btn-primary">重置</a> </div>
    </form>

    <div class="layui-field-box layui-form">
        <form name="mainform" method="post" action="{{ url('/admin/comment/dels') }}">
            <table class="layui-table" lay-size="sm">
                <thead>
                <tr>
                    <th style="width: 30px;"><input type="checkbox" lay-filter="allselector" lay-skin="primary" id="qx">
                        <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div></th>
                    <th>ID</th>
                    <th>文章</th>
                    <th>昵称</th>
                    <th>邮箱</th>
                    <th>评论</th>
                    <th>回复</th>
                    <th>审核</th>
                    <th style="width: 85px;">操作</th>
                </tr>
                </thead>
                <tbody id="content">
                @foreach ($data as $v)
                    <tr>
                        <td>
                            <input type="checkbox" name="ids[]" value="{{ $v->id }}" lay-skin="primary">
                            <div class="layui-unselect layui-form-checkbox" lay-skin="primary"><i class="layui-icon"></i></div>
                        </td>
                        <td>{{ $v->id }}</td>
                        <td><a  style="font-weight: bold;" href="/article/{{ $v->id }}" target="_blank">{{ $v->article->title }}</a></td>
                        <td>{{ $v->nickname }}</td>
                        <td>{{ $v->email }}</td>
                        <td>{{ $v->content }}</td>
                        <td>{{ $v->reply }}</td>
                        <td>
                            @if($v->is_show == 1)
                                通过
                                @else
                            <span style="color: #f60;">未通过</span>
                            @endif
                        </td>
                        <td>
                            <div class="layui-btn-group">
                                <a href="{{ url('/admin/comment/edit', array('id' => $v->id)) }}" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe642;</i> </a>
                                <a href="{{ url('/admin/comment/destroy', array('id' => $v->id)) }}" onclick="return confirm('确定要删除吗？')" class="layui-btn layui-btn-primary layui-btn-sm"> <i class="layui-icon">&#xe640;</i> </a>
                            </div>
                        </td>
                    </tr>
                @endforeach
                <tr>
                    <td colspan="9" align="center" style="padding:20px 0px;">
                        <div style="display: inline-block;padding-left: 0;">
                            共<span class="pagelink_cur_page"> {{ count($data) }} </span>个标签
                        </div>
                    </td>
                </tr>
                <tr>
                    {{ csrf_field() }}
                    <td colspan="9" align="center">
                        <a href="javascript:;" class="layui-btn layui-btn-mini" onclick="shenhe()">批量审核</a>
                        <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-mini" onclick="dels()">批量删除</a>
                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
@endsection

@section('layuijs')
    <script>
        //一般直接写在一个js文件中
        layui.use(['layer', 'form'], function(){
            var layer = layui.layer
                    ,form = layui.form;
            form.on('checkbox(allselector)', function(data){
                var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
                child.each(function(index, item){
                    item.checked = data.elem.checked;
                });
                form.render('checkbox');
            });
        });
    </script>
    <script>
        //删除
        function dels(){
            layer.confirm('是否批量删除?', {icon: 3, title:'提示'}, function(index){
                document.mainform.submit();
                layer.close(index);
            })
        }
        function shenhe(){
            layer.confirm('是否批量审核?', {icon: 3, title:'提示'}, function(index){
                document.mainform.action="{{ url('/admin/comment/shenhe') }}";
                document.mainform.submit();
                layer.close(index);
            })
        }
    </script>
@endsection